cmake_minimum_required(VERSION 3.10)

project(usb_mouse)

set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR arm)

set(tools /home/mat/workspace/Board/jz2440/cross_compatel/4.4.3)
set(CMAKE_C_COMPILER ${tools}/bin/arm-linux-gcc)
set(CMAKE_CXX_COMPILER ${tools}/bin/arm-linux-g++)

# 添加CMAKE_MODULE_PATH
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/modules")

# 设置cmake的find_package到指定路径找包 http://www.kxtry.com/archives/4000
# 1 设置库的DIR，如果find_package(Abc)
# set(Abc_DIR ~/abc-cpp-path)
# find_package(Abc REQUIRED)
# 2 设置PATHS
# set(Abc required PATHS ~/abc-cpp-path)
# 3 指定CMAKE_PREFIX_PATH
# cmake -DCMAKE_PREFIX_PATH="~/abc-cpp-path"

# 查找libusb库
list(APPEND CMAKE_PREFIX_PATH /home/mat/workspace/C/usb/libusb-1.0.23/tmp)
# set(LibUsb_DIR /home/mat/workspace/C/usb/libusb-1.0.23/tmp)
find_package(LibUsb REQUIRED)
# 包含libusb头文件
include_directories(${LIBUSB_INCLUDE_DIRS})
# 链接libusb库
link_libraries(${LIBUSB_LIBRARIES})

# 添加文件
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)
aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR}/src SRC_FILES)

add_executable(${PROJECT_NAME} ${SRC_FILES})

# 通过参数设置C99标准
set_property(TARGET ${PROJECT_NAME} PROPERTY C_STANDARD 99)
set_property(TARGET ${PROJECT_NAME} PROPERTY C_STANDARD_REQUIRED ON)

# 添加自定义命令
# make uninstall
add_custom_target("uninstall" COMMENT "Uninstall installed files")
add_custom_command(
    TARGET "uninstall"
    POST_BUILD
    COMMENT "Uninstall files with install_manifest.txt"
    COMMAND xargs rm -vf < install_manifest.txt || echo Nothing in
            install_manifest.txt to be uninstalled!
)

